<?php

declare(strict_types=1);

namespace App\Request\My;

use App\Request\BaseCommonRequest;
use Hyperf\Context\Context;
use Hyperf\Validation\Request\FormRequest;

class PhotoActionRequest extends BaseCommonRequest
{

    protected $name = 'PhotoAction';

    // protected $rules = [
    //     'action' => 'required|in:delete,update,insert,view',
    //     'image_url' => 'required_if:action,insert',
    //     'show_type' => 'required_if:action,insert,update',
    //     'id' => 'required_if:action,update,delete|array',
    // ];


    /**
     * Determine if the user is authorized to make this request.
     */
    // public function authorize(): bool
    // {
    //     return true;
    // }


    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'action' => 'required|in:delete,update,insert,view',
            'image_url' => 'required_if:action,insert',
            'show_type' => 'required_if:action,insert,update',
            'id' => 'required_if:action,update,delete|array',
        ];
    }

    // public function messages(): array
    // {
    //     $language = Context::get('language');
    //     if ($language == 'zh-zn') {
    //         return [
    //             'action.required' => '操作不能为空',
    //             'action.in' => '操作只能是 delete, update, insert, view',
    //             'image_url.required_if' => '添加时，图片地址不能为空',
    //             'show_type.required_if' => '添加和更新时，是否推荐不能为空',
    //             'id.required_if' => '更新和删除时，id不能为空',
    //             'id.array' => '视频id必须为数组',
    //         ];
    //     } elseif ($language == 'zh-hk') {
    //         return [
    //             'action.required' => '操作不得為空',
    //             'action.in' => '操作只能是 delete, update, insert, view',
    //             'image_url.required_if' => '添加時，圖片地址不得為空',
    //             'show_type.required_if' => '添加和更新時，是否推薦不得為空',
    //             'id.required_if' => '更新和删除时，id不能为空',
    //             'id.array' => '視頻id必須為數組',
    //         ];
    //     } else {
    //         return [
    //             'action.required' => 'Action is required',
    //             'action.in' => 'Action can only be delete, update, insert, view',
    //             'image_url.required_if' => 'Image url is required when insert',
    //             'show_type.required_if' => 'Show type is required when insert or update',
    //             'id.required_if' => 'Id is required when update or delete',
    //             'id.array' => 'Video id must be an array',
    //         ];
    //     }
    // }

}
